#include <iostream>
#include <cmath>
using namespace std;

struct Node {
    int val;
    struct Node* next;
};

Node* input_node() {
    int n, val;
    Node* phead = new Node();
    Node* pcur = phead;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> val;
        if (i == 1) {
            pcur->val = val;
            pcur->next = nullptr;
        }
        else {
            Node* new_pNode = new Node();
            new_pNode->val = val;
            new_pNode->next = nullptr;
            pcur->next = new_pNode;
            pcur = new_pNode;
        }
    }
    return phead;
}

Node* ReverseList(Node*& head, int l, int r) {
    Node* pHead = new Node;
    pHead->next = head;
    Node* prevNode = pHead;
    for (int i = 0; i < l - 1; i++) {
        prevNode = prevNode->next;
    }
    Node* cur = prevNode->next;
    for (int i = 0; i < r - l; i++) {
        Node* nextNode = cur->next;
        cur->next = nextNode->next;
        nextNode->next = prevNode->next;
        prevNode->next = nextNode;
    }
    Node* list = pHead->next;
    free(pHead);
    return list;
}

int main() {

    int n;
    Node* phead = input_node();

    int l, r;
    cin >> l >> r;
    Node* head = ReverseList(phead, l, r);

    while (head->next != nullptr) {
        cout << head->val << " ";
        head = head->next;
    }
    cout << head->val << endl;

    return 0;
}


int main() {

    int n = 0;
    while (cin >> n) {
        if (n == 0) break;
        long total = pow(5, n) - 4;
        long left = pow(4, n) + n - 4;
        cout << total << " " << left << endl;
    }
    return 0;
}